package com.gosophia.reportData.action;

import java.io.InputStream;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

/**
 * 文件下载
 * @author zhao_yanfang
 *
 */
@Component
@Scope("prototype")
public class AttachmentDownloadAction extends ActionSupport{


	private String fileName;
	private String filePath;
	public String execute() throws Exception {
		return Action.SUCCESS;
	}
	public InputStream getInputStream() throws Exception {
		fileName = new String(fileName.getBytes("GBK"), "ISO8859-1"); 
//		fileName = new String(fileName.getBytes(), "UTF-8");
//		fileName = java.net.URLEncoder.encode(fileName, "UTF-8"); 
		return ServletActionContext.getServletContext().getResourceAsStream(
				filePath);
	}
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	public String getFilePath() {
		return filePath;
	}
	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}
	
}
